audio_form object
This method will return the number of items in a listbox.
int get_list_count(int control_id)
Parameters:
control_id
The control ID of the listbox.
Return value:
The number of items on success, -1 on failure.
Remarks:
This method gives the number of items on a listbox, rather than the index of the final item. Therefore if you are looping through the list, you want to make sure that your counter is less than this value.
Example:
// Make a simple form with a few buttons and a listbox.
#include "form.bgt"
audio_form form;
void main()
{
form.create_window("Example Form", true);
int list=form.create_list("&People", 0);
form.add_list_item(list, "Joseph", -1);
form.add_list_item(list, "Samuel", -1);
form.add_list_item(list, "Percival", 1);
form.add_list_item(list, "William", -1);
form.add_list_item(list, "Edward", 0);
int ok=form.create_button("OK");
int cancel=form.create_button("E&xit");
while(true)
{
form.monitor();
wait(5);
if(form.is_pressed(ok))
{
alert("Information", "The listbox has "+form.get_list_count(list)+" items.");
exit();
}
if(form.is_pressed(cancel))
{
exit();
}
if((key_down(KEY_LMENU))&&(key_pressed(KEY_F4)))
{
exit();
}
}
}